<?php

   error_reporting (E_ALL);
   set_time_limit(0);
   ini_set('max_execution_time', "0");

   include('include/functions.php');

   //Подлючение к mysql
   $mysql = mysql_connect("localhost", "root", "kGbN85Z");
   mysql_query("USE ftp;");

   $sql = "SELECT id, kp_id FROM films;";
   $mres = mysql_query($sql) or die(mysql_error());

   $all = mysql_num_rows($mres) or die(mysql_error());
   $j = 1;

   $kp = new KinoPoisk();

   while($mrow = mysql_fetch_row($mres) or die(mysql_error()))
   {

      echo $j++."/".$all."  id: ".$mrow[0]."   kp_id:".$mrow[1];
      $kp->GetPage($mrow[1]);

      echo "  ".$kp->kpRaiting()."/".$kp->imdbRaiting()."\n";

      //Обновление рейтингов
      $sql = "UPDATE `films` SET `kp_raiting` = '".mysql_real_escape_string($kp->kpRaiting())."', `imdb_raiting` = '".mysql_real_escape_string($kp->imdbRaiting())."' WHERE `id` = '".$mrow[0]."';";
      mysql_query($sql);
   }

?> 
